
//
//  GrowingTextView.m
//  OSChina
//
//  Created by 8b410-2 on 17/1/5.
//  Copyright © 2017年 abb. All rights reserved.
//

#import "GrowingTextView.h"

@implementation GrowingTextView

- (instancetype)initWithPlaceholder:(NSString *)placeholder {
    self = [super init];
    if (self) {
        self.placeholder = placeholder;
        self.font = [UIFont systemFontOfSize:15];
        self.scrollEnabled = NO;
        self.scrollsToTop = NO;
        self.showsHorizontalScrollIndicator = NO;
        self.enablesReturnKeyAutomatically = YES;
        self.textContainerInset = UIEdgeInsetsMake(8, 4, 8, 0);
        self.layer.contentsScale = [UIScreen mainScreen].scale;
        _maxNumberOfLines = 4;
        _maxHeight = ceilf(self.font.lineHeight * _maxNumberOfLines + 15 + 4 * (_maxNumberOfLines - 1));
    }
    return self;
}
- (CGFloat)measureHeight {
    return ceilf([self sizeThatFits:self.frame.size].height + 10);
}


@end
